import Qs from 'qs'
import type { LANGUAGE_CODE } from "@/const";
import  { requestUpload }  from "@/utils/requestUpload";
const AIPDFTRANS ='/ai'
export interface IResponse<T = any> {
    code: number
    data: T
    message: string
    ok: boolean
    mixed_translated_content_url: string
    pure_translated_content_url: string
  }
interface ProcessStatus {
    pargh_list: string[],
    process_status: number
    languageCode: LANGUAGE_CODE
    trans_status: number
}
export const apiGetParseProcess = (data:{paperid:string}) =>{
    return requestUpload<IResponse<ProcessStatus>>({
        url: AIPDFTRANS + '/pdf_parsing_process/process_status',
        method: 'post',
        headers:{
            'Content-Type': 'application/x-www-form-urlencoded',
            // 'isNeedRequset':' true'
        },
        data: data
    })
}

export const apiSetTranStatus = (data:{paperid:string,trans_status:number}) =>{
    return requestUpload<IResponse<ProcessStatus>>({
        url: AIPDFTRANS + '/pdf_parsing_process/pdf_trans_status',
        method: 'post',
        headers:{
            'Content-Type': 'application/x-www-form-urlencoded',
            // 'isNeedRequset':' true'
        },
        data: data
    })
}
export const apiTransLate = (data:{paper_id:string,pagenum:number,docs:string}) =>{
    return requestUpload<IResponse>({
        url: AIPDFTRANS + '/pdfparsing/pdf_trans',
        method: 'post',
        data
    })
}

export const apiTransLateAll = (data:{ paperid:string }) =>{
  return requestUpload<IResponse>({
    url: AIPDFTRANS + '/pdf_parsing_process/paper_trans',
    headers:{
      'Content-Type': 'application/x-www-form-urlencoded',
      // 'isNeedRequset':' true'
  },
    method: 'post',
    data
  })
}

// 解析如果是论文 多走一次接口
export const apiParsingPaper= (data:{paperid:string}) =>{
     return requestUpload<IResponse>({
        url: AIPDFTRANS + '/pdf_parsing_process/paper_his',
        headers:{
            'Content-Type': 'application/x-www-form-urlencoded',
            // 'isNeedRequset':' true'
        },
        method: 'post',
        data: data
     })
}
// export const apiGetStartParse = (data) =>{
//     return requestUpload<IResponse>({
//         url: AIPDFTRANS + '/pdf_process',
//         method: 'post',
//         data: data
//     })
// }